package com.itheima.dubbo;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.rpc.Protocol;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws InterruptedException {

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-client.xml");
        context.start();

        //获取远程对象{dubbo默认是使用的是随机负载}
        for (int i = 0;i<10;i++) {
            IGPHello gpHello = (IGPHello) context.getBean("GpHelloService");
            System.out.println(gpHello.sayHello("wql"));
            Thread.sleep(1);
        }
        /*IDemoService demoService = (IDemoService)context.getBean("DemoService");
        System.out.println(demoService.protocolDemo("hessian"));*/

        Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension("myProtocol");
        System.out.println(protocol.getDefaultPort());

        //切入口看源码
        Protocol protocol1 = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    }
}
